﻿
using System;
using System.Collections.Generic;
using System.Linq;
using UMC.Web;
using System.Text;
using System.Security.Cryptography;

namespace UMC.ITME.Activities
{
    [UMC.Web.Apiumc("UI", "Config", Auth = WebAuthType.All)]
    public class UIConfigActivity : UMC.Web.WebActivity
    {
        public override void ProcessActivity(WebRequest request, WebResponse response)
        {
            var config = this.AsyncDialog("Type", "defalut");
            switch (config)
            {
                case "Bar":
                    break;
                default:
                case "Home":
                    if (this.Context.Client.Context.Headers.Get("itme-app-id"u8).IsEmpty== false)
                    {
                        var footBar = new List<WebMeta> {
                            new WebMeta().Put("text", "应用", "key", "Pager", "cmd", "UI", "model", "ITME", "icon", "\uf1b3", "RefreshEvent", "ITME.Site"),
                            new WebMeta("text", "扫 一 扫", "icon", "\uf2e1").Put("max", true).Put("click", UIClick.Scanning()),
                            new WebMeta().Put("text", "我的", "key", "Pager", "cmd", "Self", "model", "Account", "icon", "", "RefreshEvent", "UI.Setting,Account.Gather").Put("search", new WebMeta("Type", "Setting"))
                        };
                        this.Context.Reset(new WebMeta().Put("footBar", footBar));
                    }
                    break;
            }
        }

    }

    [Apiumc("System", "Scanning", Auth = WebAuthType.All, Desc = "移动扫描", Weight = 1)]
    class SiteScanningActivity : UMC.Web.Activities.SystemScanningActivity
    {
        protected override void Scanning(Uri url)
        {
            if (url.Host.Contains("apiumc.cn") || url.Host.Contains("apiumc.com"))
            {
                if (url.AbsolutePath.StartsWith("/UMC/Platform/Apper"))
                {
                    var Setup = System.Web.HttpUtility.ParseQueryString(url.Query).Get("Setup");
                    this.Context.Send(new UIClick("ITME", "Setup").Send(new WebMeta("_", Setup)), true);


                }
            }
            base.Scanning(url);
        }
    }
}